<?php

namespace addons\yiliao\controller\api;

use addons\yiliao\controller\api\User as ApiUser;
use app\admin\model\yiliao\Banner as BannerModel;
use app\admin\model\yiliao\Promotion as PromotionModel;
use app\admin\model\yiliao\User;

class Banner extends Base
{
    public function _initialize()
    {
        parent::_initialize();
    }
    
    
    public function getBanner()
    {
        $hd = PromotionModel::where(['start_time'=>['<',time()],'end_time'=>['>',time()]])->where(['status'=>'normal'])->field('id,image')->select();
        foreach ($hd as $k1 => $v1) {
            $hd[$k1]['is_type'] = 1;
            $hd[$k1]['image'] = cdnurl($v1['image'], true);
        }
        $rows = BannerModel::where(['status'=>'normal', 'cate'=>'index'])->order('paixu desc,id desc')->field('id,image')->select();
        foreach ($rows as $k => $v) {
            $rows[$k]['is_type'] = 0;
            $rows[$k]['image'] = cdnurl($v['image'], true);
        }
        $arr = array_merge($hd, $rows);
        $this->success('', $arr);
    }
}
